package com.project.server.mapper;

import com.project.server.model.Dish;
import com.project.server.vo.RevenueVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface DashboardMapper {

    @Select("SELECT COUNT(*) FROM orders WHERE DATE(create_time) = CURDATE()")
    Integer getTodayOrderCount();

    @Select("SELECT COUNT(*) FROM orders WHERE status = 0")
    Integer getPendingOrderCount();

    @Select("SELECT COUNT(*) FROM dish")
    Integer getTotalDishCount();

    @Select("SELECT COUNT(*) FROM dish WHERE status = 1")
    Integer getActiveDishCount();

    @Select("SELECT COUNT(*) FROM dish WHERE status = 0")
    Integer getInactiveDishCount();

    @Select("SELECT COUNT(*) FROM dish WHERE status = 1 AND sales > 0")
    Integer getHotDishCount();

    @Select("SELECT d.*, c.name as category_name " +
            "FROM dish d " +
            "LEFT JOIN dish_category c ON d.category_id = c.id " +
            "WHERE d.status = 1 " +
            "ORDER BY d.sales DESC LIMIT #{limit}")
    List<Dish> getHotDishes(@Param("limit") Long limit);

}
